#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
	int maximumGood(vector<vector<int>>& statements)
	{
		int amount = size(statements);
		vector vis(amount, false);

		unordered_set<int> rest;
		int res = 0;
		for (int i = 0; i < amount; i++) {
			rest.clear();
			for (int it = 0; it < amount; it++) rest.emplace(it);
			fill(begin(vis), end(vis), false);
			vis[i] = true;
			for (int j = 0; j < amount; j++)
				if (!rest.count(j) || vis[j]) continue;
				else if (statements[i][j] == 0)
					rest.erase(j);
				else if (statements[i][j] == 1)
					dfs(vis, rest, statements, j);
				else {
					for (int o: statements[j])
						if (o == 0) {
							rest.erase(j);
							break;
						}
				}
			res = max(res, (int)size(rest));
			printf("\n\t%d:\n", i);
			for (auto io: rest) cout << io << '\t';
		}
		return res;
	}

private:
	void dfs(vector<bool>& vis, unordered_set<int>& rest, vector<vector<int>>& statements, int commenter)
	{
		vis[commenter] = true;
		for (int j = 0, amount = size(statements); j < amount; j++)
			if (!rest.count(j) || vis[j]) continue;
			else if (statements[commenter][j] == 0)
				rest.erase(j);
			else if (statements[commenter][j] == 1)
				dfs(vis, rest, statements, j);
			else {
				for (int o: statements[j])
					if (o == 0) {
						rest.erase(j);
						break;
					}
			}
		vis[commenter] = false;
	}
};

int main()
{
	[[maybe_unused]] Solution solution;
	return 0;
}
